using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class UserInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			Username,
			Password,
			Email,
			Regdate,
			Ip,
			Firstname,
			Lastname,
			Birthdate,
			Birthplace,
			Ssn,
			GroupCode,
			ANAL_U0,
			ANAL_U1,
			ANAL_U2,
			ANAL_U3,
			ANAL_U4,
			ANAL_U5,
			ANAL_U6,
			ANAL_U7,
			ANAL_U8,
			ANAL_U9
		}
		private Int64 _ID;
		private String _Username;
		private String _Password;
		private String _Email;
		private Int32 _Regdate;
		private String _Ip;
		private String _Firstname;
		private String _Lastname;
		private Int32 _Birthdate;
		private String _Birthplace;
		private String _Ssn;
		private String _GroupCode;
		private String _ANAL_U0;
		private String _ANAL_U1;
		private String _ANAL_U2;
		private String _ANAL_U3;
		private String _ANAL_U4;
		private String _ANAL_U5;
		private String _ANAL_U6;
		private String _ANAL_U7;
		private String _ANAL_U8;
		private String _ANAL_U9;
		
		public Int64 ID{	get{ return _ID;} set{_ID = value;} }
		public String Username{	get{ return _Username;} set{_Username = value;} }
		public String Password{	get{ return _Password;} set{_Password = value;} }
		public String Email{	get{ return _Email;} set{_Email = value;} }
		public Int32 Regdate{	get{ return _Regdate;} set{_Regdate = value;} }
		public String Ip{	get{ return _Ip;} set{_Ip = value;} }
		public String Firstname{	get{ return _Firstname;} set{_Firstname = value;} }
		public String Lastname{	get{ return _Lastname;} set{_Lastname = value;} }
		public Int32 Birthdate{	get{ return _Birthdate;} set{_Birthdate = value;} }
		public String Birthplace{	get{ return _Birthplace;} set{_Birthplace = value;} }
		public String Ssn{	get{ return _Ssn;} set{_Ssn = value;} }
		public String GroupCode{	get{ return _GroupCode;} set{_GroupCode = value;} }
		public String ANAL_U0{	get{ return _ANAL_U0;} set{_ANAL_U0 = value;} }
		public String ANAL_U1{	get{ return _ANAL_U1;} set{_ANAL_U1 = value;} }
		public String ANAL_U2{	get{ return _ANAL_U2;} set{_ANAL_U2 = value;} }
		public String ANAL_U3{	get{ return _ANAL_U3;} set{_ANAL_U3 = value;} }
		public String ANAL_U4{	get{ return _ANAL_U4;} set{_ANAL_U4 = value;} }
		public String ANAL_U5{	get{ return _ANAL_U5;} set{_ANAL_U5 = value;} }
		public String ANAL_U6{	get{ return _ANAL_U6;} set{_ANAL_U6 = value;} }
		public String ANAL_U7{	get{ return _ANAL_U7;} set{_ANAL_U7 = value;} }
		public String ANAL_U8{	get{ return _ANAL_U8;} set{_ANAL_U8 = value;} }
		public String ANAL_U9{	get{ return _ANAL_U9;} set{_ANAL_U9 = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public UserInfo()
		{
			_ID = 0;
			_Username = "";
			_Password = "";
			_Email = "";
			_Regdate = 0;
			_Ip = "";
			_Firstname = "";
			_Lastname = "";
			_Birthdate = 0;
			_Birthplace = "";
			_Ssn = "";
			_GroupCode = "";
			_ANAL_U0 = "";
			_ANAL_U1 = "";
			_ANAL_U2 = "";
			_ANAL_U3 = "";
			_ANAL_U4 = "";
			_ANAL_U5 = "";
			_ANAL_U6 = "";
			_ANAL_U7 = "";
			_ANAL_U8 = "";
			_ANAL_U9 = "";
		}
		public UserInfo(
		Int64 ID,
		String Username,
		String Password,
		String Email,
		Int32 Regdate,
		String Ip,
		String Firstname,
		String Lastname,
		Int32 Birthdate,
		String Birthplace,
		String Ssn,
		String GroupCode,
		String ANAL_U0,
		String ANAL_U1,
		String ANAL_U2,
		String ANAL_U3,
		String ANAL_U4,
		String ANAL_U5,
		String ANAL_U6,
		String ANAL_U7,
		String ANAL_U8,
		String ANAL_U9
		)
		{
			_ID = ID;
			_Username = Username;
			_Password = Password;
			_Email = Email;
			_Regdate = Regdate;
			_Ip = Ip;
			_Firstname = Firstname;
			_Lastname = Lastname;
			_Birthdate = Birthdate;
			_Birthplace = Birthplace;
			_Ssn = Ssn;
			_GroupCode = GroupCode;
			_ANAL_U0 = ANAL_U0;
			_ANAL_U1 = ANAL_U1;
			_ANAL_U2 = ANAL_U2;
			_ANAL_U3 = ANAL_U3;
			_ANAL_U4 = ANAL_U4;
			_ANAL_U5 = ANAL_U5;
			_ANAL_U6 = ANAL_U6;
			_ANAL_U7 = ANAL_U7;
			_ANAL_U8 = ANAL_U8;
			_ANAL_U9 = ANAL_U9;
		}
		public UserInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.ID.ToString()]);
				_Username = dr[Field.Username.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Username.ToString()]);
				_Password = dr[Field.Password.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Password.ToString()]);
				_Email = dr[Field.Email.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Email.ToString()]);
				_Regdate = dr[Field.Regdate.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Regdate.ToString()]);
				_Ip = dr[Field.Ip.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Ip.ToString()]);
				_Firstname = dr[Field.Firstname.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Firstname.ToString()]);
				_Lastname = dr[Field.Lastname.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Lastname.ToString()]);
				_Birthdate = dr[Field.Birthdate.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Birthdate.ToString()]);
				_Birthplace = dr[Field.Birthplace.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Birthplace.ToString()]);
				_Ssn = dr[Field.Ssn.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Ssn.ToString()]);
				_GroupCode = dr[Field.GroupCode.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.GroupCode.ToString()]);
				_ANAL_U0 = dr[Field.ANAL_U0.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U0.ToString()]);
				_ANAL_U1 = dr[Field.ANAL_U1.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U1.ToString()]);
				_ANAL_U2 = dr[Field.ANAL_U2.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U2.ToString()]);
				_ANAL_U3 = dr[Field.ANAL_U3.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U3.ToString()]);
				_ANAL_U4 = dr[Field.ANAL_U4.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U4.ToString()]);
				_ANAL_U5 = dr[Field.ANAL_U5.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U5.ToString()]);
				_ANAL_U6 = dr[Field.ANAL_U6.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U6.ToString()]);
				_ANAL_U7 = dr[Field.ANAL_U7.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U7.ToString()]);
				_ANAL_U8 = dr[Field.ANAL_U8.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U8.ToString()]);
				_ANAL_U9 = dr[Field.ANAL_U9.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_U9.ToString()]);
			}
		}
		public UserInfo(UserInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_Username = objEntr.Username;			
			_Password = objEntr.Password;			
			_Email = objEntr.Email;			
			_Regdate = objEntr.Regdate;			
			_Ip = objEntr.Ip;			
			_Firstname = objEntr.Firstname;			
			_Lastname = objEntr.Lastname;			
			_Birthdate = objEntr.Birthdate;			
			_Birthplace = objEntr.Birthplace;			
			_Ssn = objEntr.Ssn;			
			_GroupCode = objEntr.GroupCode;			
			_ANAL_U0 = objEntr.ANAL_U0;			
			_ANAL_U1 = objEntr.ANAL_U1;			
			_ANAL_U2 = objEntr.ANAL_U2;			
			_ANAL_U3 = objEntr.ANAL_U3;			
			_ANAL_U4 = objEntr.ANAL_U4;			
			_ANAL_U5 = objEntr.ANAL_U5;			
			_ANAL_U6 = objEntr.ANAL_U6;			
			_ANAL_U7 = objEntr.ANAL_U7;			
			_ANAL_U8 = objEntr.ANAL_U8;			
			_ANAL_U9 = objEntr.ANAL_U9;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("tblUser");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int64)),
				new DataColumn(Field.Username.ToString(), typeof(String)),
				new DataColumn(Field.Password.ToString(), typeof(String)),
				new DataColumn(Field.Email.ToString(), typeof(String)),
				new DataColumn(Field.Regdate.ToString(), typeof(Int32)),
				new DataColumn(Field.Ip.ToString(), typeof(String)),
				new DataColumn(Field.Firstname.ToString(), typeof(String)),
				new DataColumn(Field.Lastname.ToString(), typeof(String)),
				new DataColumn(Field.Birthdate.ToString(), typeof(Int32)),
				new DataColumn(Field.Birthplace.ToString(), typeof(String)),
				new DataColumn(Field.Ssn.ToString(), typeof(String)),
				new DataColumn(Field.GroupCode.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U0.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U1.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U2.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U3.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U4.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U5.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U6.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U7.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U8.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_U9.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.Username.ToString()] = _Username;
			row[Field.Password.ToString()] = _Password;
			row[Field.Email.ToString()] = _Email;
			row[Field.Regdate.ToString()] = _Regdate;
			row[Field.Ip.ToString()] = _Ip;
			row[Field.Firstname.ToString()] = _Firstname;
			row[Field.Lastname.ToString()] = _Lastname;
			row[Field.Birthdate.ToString()] = _Birthdate;
			row[Field.Birthplace.ToString()] = _Birthplace;
			row[Field.Ssn.ToString()] = _Ssn;
			row[Field.GroupCode.ToString()] = _GroupCode;
			row[Field.ANAL_U0.ToString()] = _ANAL_U0;
			row[Field.ANAL_U1.ToString()] = _ANAL_U1;
			row[Field.ANAL_U2.ToString()] = _ANAL_U2;
			row[Field.ANAL_U3.ToString()] = _ANAL_U3;
			row[Field.ANAL_U4.ToString()] = _ANAL_U4;
			row[Field.ANAL_U5.ToString()] = _ANAL_U5;
			row[Field.ANAL_U6.ToString()] = _ANAL_U6;
			row[Field.ANAL_U7.ToString()] = _ANAL_U7;
			row[Field.ANAL_U8.ToString()] = _ANAL_U8;
			row[Field.ANAL_U9.ToString()] = _ANAL_U9;
			return row;
		}
        #endregion InitTable
    }
}
